#include <STC15F2K60S2.H>
#include "smg.h"
#include "Key.h"
#include "Delay.h"
#include "DS1302.h"

unsigned char Keynum;
unsigned char Show_Flag = 0;
void main()
{
	All_Init();
	DS1302_Init();
	
	DS1302_SetTime();
	
	while(1)
	{
		Keynum = Duli_Anjian();
		DS1302_ReadTime();
		if		(Keynum == 7) Show_Flag = 0;	//按键7
		else if (Keynum == 6) Show_Flag = 1;	//按键6
		else if (Keynum == 5) Show_Flag = 2;
		
		if (0 == Show_Flag)//按键7 或默认状态
		{
			Nixie(1, DS1302_Time[3]/10);	//时
			Nixie(2, DS1302_Time[3]%10);
			Nixie(3, 16);	//显示 -
			Nixie(4, DS1302_Time[4]/10);	//分
			Nixie(5, DS1302_Time[4]%10);
			Nixie(6, 16);	//显示 -
			Nixie(7, DS1302_Time[5]/10);	//秒
			Nixie(8, DS1302_Time[5]%10);
		}
		else if (1 == Show_Flag)//按键6
		{
			Nixie(1, DS1302_Time[0]/10);	//年
			Nixie(2, DS1302_Time[0]%10);
			Nixie(3, 16);	//显示 -
			Nixie(4, DS1302_Time[1]/10);	//月
			Nixie(5, DS1302_Time[1]%10);
			Nixie(6, 16);	//显示 -
			Nixie(7, DS1302_Time[2]/10); 	//日
			Nixie(8, DS1302_Time[2]%10);
		}
		else if (2 == Show_Flag)
		{
			Nixie(1, DS1302_Time[6]);
			Nixie(2,17);	//熄灭码
			Nixie(3,17);	
			Nixie(4,17);
			Nixie(5,17);
			Nixie(6,17);
			Nixie(7,17);
			Nixie(8,17);
		}
		
	}
}
